package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HyRatings;
import com.ruoyi.system.service.IHyRatingsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 影视评分Controller
 * 
 * @author ruoyi
 * @date 2025-06-19
 */
@RestController
@RequestMapping("/system/ratings")
public class HyRatingsController extends BaseController
{
    @Autowired
    private IHyRatingsService hyRatingsService;

    /**
     * 查询影视评分列表
     */
    @PreAuthorize("@ss.hasPermi('system:ratings:list')")
    @GetMapping("/list")
    public TableDataInfo list(HyRatings hyRatings)
    {
        startPage();
        List<HyRatings> list = hyRatingsService.selectHyRatingsList(hyRatings);
        return getDataTable(list);
    }

    /**
     * 导出影视评分列表
     */
    @PreAuthorize("@ss.hasPermi('system:ratings:export')")
    @Log(title = "影视评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HyRatings hyRatings)
    {
        List<HyRatings> list = hyRatingsService.selectHyRatingsList(hyRatings);
        ExcelUtil<HyRatings> util = new ExcelUtil<HyRatings>(HyRatings.class);
        util.exportExcel(response, list, "影视评分数据");
    }

    /**
     * 获取影视评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ratings:query')")
    @GetMapping(value = "/{ratingsId}")
    public AjaxResult getInfo(@PathVariable("ratingsId") Long ratingsId)
    {
        return success(hyRatingsService.selectHyRatingsByRatingsId(ratingsId));
    }

    /**
     * 新增影视评分
     */
    @PreAuthorize("@ss.hasPermi('system:ratings:add')")
    @Log(title = "影视评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HyRatings hyRatings)
    {
        return toAjax(hyRatingsService.insertHyRatings(hyRatings));
    }

    /**
     * 修改影视评分
     */
    @PreAuthorize("@ss.hasPermi('system:ratings:edit')")
    @Log(title = "影视评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HyRatings hyRatings)
    {
        return toAjax(hyRatingsService.updateHyRatings(hyRatings));
    }

    /**
     * 删除影视评分
     */
    @PreAuthorize("@ss.hasPermi('system:ratings:remove')")
    @Log(title = "影视评分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ratingsIds}")
    public AjaxResult remove(@PathVariable Long[] ratingsIds)
    {
        return toAjax(hyRatingsService.deleteHyRatingsByRatingsIds(ratingsIds));
    }
}
